package com.heima.article.feign;

import com.heima.apis.article.IArticleClient;
import com.heima.article.service.ApArticleConfigService;
import com.heima.article.service.ArticleService;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.pojos.ApArticleConfig;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ManageDto;
import com.heima.model.wemedia.vos.ManageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ArticleClient implements IArticleClient {

    @Autowired
    private ArticleService articleService;
    @Autowired
    private ApArticleConfigService apArticleConfigService;

    @PostMapping("/api/v1/article/save")
    @Override
    public ResponseResult saveArticle(@RequestBody ArticleDto dto) {
        return articleService.saveArticle(dto);
    }

    @PostMapping("/api/v1/article/manage")
    @Override
    public PageResponseResult getNewsList(@RequestBody ManageDto dto) {
        return articleService.getNewsList(dto);
    }

    @PostMapping("/api/v1/article/isComment")
    @Override
    public String getIsComment(Long articleId) {
        return apArticleConfigService.getIsComment(articleId);
    }
    @PostMapping("/api/v1/article/getArticleConfig")
    @Override
    public void getArticleConfig(Long articleId, int start) {
        apArticleConfigService.updateConfig(articleId,start);
    }




}
